<template>
  <el-dialog title="划转资产明细" :close-on-click-modal="false" :visible.sync="visible" width="1200px">
    <div class="filter-container">
      <el-form :inline="true" :model="searchForm" class="demo-form-inline">
        <el-form-item label="商品名称: " >
          <el-input clearable v-model="searchForm.prodName" placeholder="请输入" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="denomId: " >
          <el-input clearable v-model="searchForm.denomId" placeholder="请输入" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="铸币类别名称: " >
          <el-input clearable v-model="searchForm.denomName" placeholder="请输入" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="发起方Id: " >
          <el-input clearable v-model="searchForm.holdUserId" placeholder="请输入" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="发起方名称: " >
          <el-input clearable v-model="searchForm.nickName" placeholder="请输入" size="mini"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="mini" icon="el-icon-search" @click="searchChange(true)">查询</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="clearSearch">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-table :data="dataList" border style="width: 100%" :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }">
      <el-table-column prop="appId" label="申请Id" min-width="90" align="center"/>
      <el-table-column prop="batchId" label="批次Id" min-width="50" align="center"/>
      <el-table-column prop="prodName" label="商品名称" min-width="100" align="center"/>
      <el-table-column prop="denomName" label="铸币类别名称" min-width="100" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-popover placement="top" trigger="hover" >
            <div>{{ scope.row.denomeId }}</div>
            <div slot="reference" class="name-wrapper">
              <div>{{ scope.row.denomName }}</div>
            </div>
          </el-popover>
        </template>
      </el-table-column>
<!--      <el-table-column prop="tokenId" label="tokenId" min-width="100" align="center" />-->
      <el-table-column prop="nickName" label="发起方" min-width="100" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-popover placement="top" trigger="hover" >
            <div>{{ scope.row.holdUserId }}</div>
            <div slot="reference" class="name-wrapper">
              <div>{{ scope.row.nickName }}</div>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column prop="userId" label="海文交userId" min-width="100" align="center" />
      <el-table-column prop="status" label="转出状态" align="center" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 0 && scope.row.type === 0" size="small" type="success" effect="dark">转出成功</el-tag>
          <el-tag v-if="scope.row.type === 1" size="small" type="success" effect="dark">转出成功</el-tag>
          <el-tag v-if="scope.row.status === 1 && scope.row.type === 0" size="small" type="warning" effect="dark">转出中</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="转出时间" align="center" />

      <el-table-column prop="status" label="转入状态" align="center" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 0 && scope.row.type === 1" size="small" type="success" effect="dark">转入成功</el-tag>
          <el-tag v-if="scope.row.status === 1 && scope.row.type === 1" size="small" type="warning" effect="dark">转入中</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="updateTime" label="转入时间" align="center" >
        <template slot-scope="scope">
            <span v-if="scope.row.type === 1" >{{ scope.row.updateTime }}</span>
        </template>
      </el-table-column>

    </el-table>

    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.currentPage"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="page.pageSize"
      :total="page.total"
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      visible: false,
      dataListLoading: false,
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条,
      },
      searchForm: {
        prodName: '',
        denomId: '',
        denomName: '',
        tokenId: '',
        holdUserId: '',
        nickName: ''
      },
      dataList: []
    }
  },
  mounted () {
  },
  methods: {
    init (tokenId) {
      this.dataList = []
      this.visible = true
      // 获取列表信息
      this.searchForm.tokenId = tokenId
      if (this.searchForm.tokenId) {
        this.getDataList()
      }
    },
    getDataList (page, newData = false) {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl(`/admin/transferRecord/page`),
        method: 'get',
        params: this.$http.adornParams(
          Object.assign({
            current: page == null ? this.page.currentPage : page.currentPage,
            size: page == null ? this.page.pageSize : page.pageSize
          },
            this.searchForm
          )
        )
      }).then(({ data }) => {
        this.dataList = data.records
        this.page.total = data.total
        this.dataListLoading = false
      })
    },
    searchChange (newData = false) {
      this.page.currentPage = 1
      this.getDataList(this.page, newData)
    },
    clearSearch () {
      this.searchForm.prodName = ''
      this.searchForm.denomId = ''
      this.searchForm.denomName = ''
      this.searchForm.holdUserId = ''
      this.searchForm.nickName = ''
      this.page.currentPage = 1
      this.getDataList(this.page, true) // 重置表单加载初始数据
    },
    // 分页按钮
    handleSizeChange (val) {
      this.page.pageSize = val
      this.getDataList(this.page)
    },
    handleCurrentChange (val) {
      this.page.currentPage = val
      this.getDataList(this.page)
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  .img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100px;
  }
}
.el-popover{
  color: #fff !important;
  background:#000 !important;
  padding: 8px !important;
  font-size: 12px !important;
}
.el-popper[x-placement^=left] .popper__arrow::after{
  border-left-color: #000 !important;
}
.el-popper[x-placement^=right] .popper__arrow::after{
  border-right-color: #000 !important;
}
.el-popper[x-placement^=bottom] .popper__arrow::after{
  border-bottom-color: #000 !important;
}
.el-popper[x-placement^=top] .popper__arrow::after{
  border-top-color: #000 !important;
}
</style>
